import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        User user = login();
        BookList bookList = new BookList();
        while (true) {
            int choice = user.menu();
            if (choice == -1) {
                System.out.println("ByeBye!!!");
                break;
            }else if (choice >= 1 && choice <= 5) {
                user.doOperation(choice, bookList);
            }else {
                    System.err.println("输入错误，请重新输入!");
            }
        }
    }

    public static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String userName = scanner.next();
        System.out.println("请输入你的身份:1.普通用户   2.管理员");
        int choice = scanner.nextInt();
        if (choice == 1) {
            return new NormalUser(userName);
        }
        return new AdminUser(userName);
    }
}
